import { Nodes } from '@knno/dom';
import { TitleBarEventMap, TitleBar as UITitleBar } from '../components/titleBar/titleBar';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, On, isBool, isStr, jsxBuild } from './utils';

export { UITitleBar };

interface TitleBarProps extends JSXProps<UITitleBar>, On<TitleBarEventMap, UITitleBar> {
	navback?: boolean;
	rightIcon?: string | null;
	title?: string;
}

const ATTRS: AttrCheck = {
	navback: isBool,
	rightIcon: isStr,
	title: isStr,
};

export function TitleBar(props: TitleBarProps, children: Nodes[]): UITitleBar {
	return jsxBuild(new UITitleBar(), props, children, ATTRS);
}
